import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css'
import '../src/assets/css/global.css'

import axios from 'axios'
// axios.defaults.baseURL = '/api'

axios.defaults.baseURL = 'http://localhost:8083'

//请求拦截器
axios.interceptors.request.use(config => {
  // console.log(config);
  //进度条
 
  const token = window.sessionStorage.getItem("token")

  // config.headers.Authorization = window.sessionStorage.getItem('token')
  if (token) {
    // 判断是否存在token，如果存在的话，则每个http header都加上token
    // Bearer是JWT的认证头部信息
    config.headers.common["Authorization"] = "Bearer " + token;
  }
  //必须returnconfig
  console.log(token, 'token');
  return config
})
//响应拦截器
axios.interceptors.response.use(config => {

  return config
})

Vue.prototype.$http = axios

Vue.config.productionTip = false

Vue.use(ElementUI)

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
